Add ot-gpg-utils.[ch] and move _ostree_gpg_error_to_gio_error() here.
endif
libostree_1_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/bsdiff -I$(srcdir)/libglnx -I$(srcdir)/src/libotutil -I$(srcdir)/src/libostree \
- $(OT_INTERNAL_GIO_UNIX_CFLAGS) $(OT_DEP_LZMA_CFLAGS) $(OT_DEP_ZLIB_CFLAGS)
+ $(OT_INTERNAL_GIO_UNIX_CFLAGS) $(OT_INTERNAL_GPGME_CFLAGS) $(OT_DEP_LZMA_CFLAGS) $(OT_DEP_ZLIB_CFLAGS)
libostree_1_la_LDFLAGS = -version-number 1:0:0 -Bsymbolic-functions -export-symbols-regex '^ostree_'
-libostree_1_la_LIBADD = libotutil.la libbupsplit.la libglnx.la libbsdiff.la libostree-kernel-args.la $(OT_INTERNAL_GIO_UNIX_LIBS) $(OT_DEP_LZMA_LIBS) $(OT_DEP_ZLIB_LIBS) $(GPGME_LIBS)
+libostree_1_la_LIBADD = libotutil.la libbupsplit.la libglnx.la libbsdiff.la libostree-kernel-args.la $(OT_INTERNAL_GIO_UNIX_LIBS) $(OT_INTERNAL_GPGME_LIBS) $(OT_DEP_LZMA_LIBS) $(OT_DEP_ZLIB_LIBS)
if USE_LIBARCHIVE
libostree_1_la_CFLAGS += $(OT_DEP_LIBARCHIVE_CFLAGS)
src/libotutil/ot-variant-utils.h \
src/libotutil/ot-gio-utils.c \
src/libotutil/ot-gio-utils.h \
+ src/libotutil/ot-gpg-utils.c \
+ src/libotutil/ot-gpg-utils.h \
src/libotutil/otutil.c \
src/libotutil/otutil.h \
src/libotutil/ot-tool-util.c \
src/libotutil/ot-tool-util.h \
$(NULL)
-libotutil_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/libglnx -I$(srcdir)/src/libotutil -DLOCALEDIR=\"$(datadir)/locale\" $(OT_INTERNAL_GIO_UNIX_CFLAGS)
-libotutil_la_LIBADD = $(OT_INTERNAL_GIO_UNIX_LIBS)
+libotutil_la_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/libglnx -I$(srcdir)/src/libotutil -DLOCALEDIR=\"$(datadir)/locale\" $(OT_INTERNAL_GIO_UNIX_CFLAGS) $(OT_INTERNAL_GPGME_CFLAGS)
+libotutil_la_LIBADD = $(OT_INTERNAL_GIO_UNIX_LIBS) $(OT_INTERNAL_GPGME_LIBS)
OT_INTERNAL_SOUP_CFLAGS = $(OT_DEP_SOUP_CFLAGS)
OT_INTERNAL_SOUP_LIBS = $(OT_DEP_SOUP_LIBS)
+# This canonicalizes the PKG_CHECK_MODULES or AM_PATH_GPGME results
+OT_INTERNAL_GPGME_CFLAGS = $(OT_DEP_GPGME_CFLAGS) $(GPGME_CFLAGS)
+OT_INTERNAL_GPGME_LIBS = $(OT_DEP_GPGME_LIBS) $(GPGME_LIBS)
+
if BUILDOPT_INTROSPECTION
include $(INTROSPECTION_MAKEFILE)
GIRS =
#include <stdlib.h>
#include <glib/gstdio.h>
-#include <gpgme.h>
typedef struct {
GObjectClass parent_class;
home_dir);
if (gpg_error != GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (gpg_error, error);
+ ot_gpgme_error_to_gio_error (gpg_error, error);
goto out;
}
0 /* do not copy */);
if (gpg_error != GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (gpg_error, error);
+ ot_gpgme_error_to_gio_error (gpg_error, error);
g_prefix_error (error, "Unable to read signed data: ");
goto out;
}
0 /* do not copy */);
if (gpg_error != GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (gpg_error, error);
+ ot_gpgme_error_to_gio_error (gpg_error, error);
g_prefix_error (error, "Unable to read signature: ");
goto out;
}
gpg_error = gpgme_op_verify (result->context, signature_buffer, data_buffer, NULL);
if (gpg_error != GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (gpg_error, error);
+ ot_gpgme_error_to_gio_error (gpg_error, error);
g_prefix_error (error, "Unable to complete signature verification: ");
goto out;
}
#include "ostree-gpg-verify-result.h"
-#include <gpgme.h>
+#include "otutil.h"
/**
* OstreeGpgVerifyResult:
gpgme_ctx_t context;
gpgme_verify_result_t details;
};
-
-/* XXX Split these into a separate "GPGME utilities" file? */
-
-void _ostree_gpg_error_to_gio_error (gpgme_error_t gpg_error, GError **error);
-
#include "ostree-gpg-verify-result-private.h"
-#include <gpgme.h>
-
/**
* SECTION: libostree-gpg-verify-result
* @title: GPG signature verification results
gpg_error = gpgme_new (&result->context);
if (gpg_error != GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (gpg_error, error);
+ ot_gpgme_error_to_gio_error (gpg_error, error);
g_prefix_error (error, "Unable to create context: ");
goto out;
}
}
}
}
-
-void
-_ostree_gpg_error_to_gio_error (gpgme_error_t gpg_error,
- GError **error)
-{
- GIOErrorEnum errcode;
-
- /* XXX This list is incomplete. Add cases as needed. */
-
- switch (gpg_error)
- {
- /* special case - shouldn't be here */
- case GPG_ERR_NO_ERROR:
- g_return_if_reached ();
-
- /* special case - abort on out-of-memory */
- case GPG_ERR_ENOMEM:
- g_error ("%s: %s",
- gpgme_strsource (gpg_error),
- gpgme_strerror (gpg_error));
-
- case GPG_ERR_INV_VALUE:
- errcode = G_IO_ERROR_INVALID_ARGUMENT;
- break;
-
- default:
- errcode = G_IO_ERROR_FAILED;
- break;
- }
-
- g_set_error (error, G_IO_ERROR, errcode, "%s: %s",
- gpgme_strsource (gpg_error),
- gpgme_strerror (gpg_error));
-}
#include "ostree-repo-file-enumerator.h"
#include "ostree-gpg-verifier.h"
-/* XXX Only for _ostree_gpg_error_to_gio_error(). Move it elsewhere? */
-#include "ostree-gpg-verify-result-private.h"
-
#include <locale.h>
-#include <gpgme.h>
#include <glib/gstdio.h>
/**
if ((err = gpgme_new (&context)) != GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (err, error);
+ ot_gpgme_error_to_gio_error (err, error);
g_prefix_error (error, "Unable to create gpg context: ");
goto out;
}
if ((err = gpgme_set_protocol (context, GPGME_PROTOCOL_OpenPGP)) !=
GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (err, error);
+ ot_gpgme_error_to_gio_error (err, error);
g_prefix_error (error, "Unable to set gpg protocol: ");
goto out;
}
if ((err = gpgme_ctx_set_engine_info (context, info->protocol, NULL, homedir))
!= GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (err, error);
+ ot_gpgme_error_to_gio_error (err, error);
g_prefix_error (error, "Unable to set gpg homedir to '%s': ",
homedir);
goto out;
}
else if (err != GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (err, error);
+ ot_gpgme_error_to_gio_error (err, error);
g_prefix_error (error, "Unable to lookup key ID %s: ", key_id);
goto out;
}
/* Add the key to the context as a signer */
if ((err = gpgme_signers_add (context, key)) != GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (err, error);
+ ot_gpgme_error_to_gio_error (err, error);
g_prefix_error (error, "Error signing commit: ");
goto out;
}
const char *buf = g_bytes_get_data (input_data, &len);
if ((err = gpgme_data_new_from_mem (&commit_buffer, buf, len, FALSE)) != GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (err, error);
+ ot_gpgme_error_to_gio_error (err, error);
g_prefix_error (error, "Failed to create buffer from commit file: ");
goto out;
}
if ((err = gpgme_data_new_from_fd (&signature_buffer, signature_fd)) != GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (err, error);
+ ot_gpgme_error_to_gio_error (err, error);
g_prefix_error (error, "Failed to create buffer for signature file: ");
goto out;
}
if ((err = gpgme_op_sign (context, commit_buffer, signature_buffer, GPGME_SIG_MODE_DETACH))
!= GPG_ERR_NO_ERROR)
{
- _ostree_gpg_error_to_gio_error (err, error);
+ ot_gpgme_error_to_gio_error (err, error);
g_prefix_error (error, "Failure signing commit file: ");
goto out;
}
--- /dev/null
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include "ot-gpg-utils.h"
+
+void
+ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error,
+ GError **error)
+{
+ GIOErrorEnum errcode;
+
+ /* XXX This list is incomplete. Add cases as needed. */
+
+ switch (gpg_error)
+ {
+ /* special case - shouldn't be here */
+ case GPG_ERR_NO_ERROR:
+ g_return_if_reached ();
+
+ /* special case - abort on out-of-memory */
+ case GPG_ERR_ENOMEM:
+ g_error ("%s: %s",
+ gpgme_strsource (gpg_error),
+ gpgme_strerror (gpg_error));
+
+ case GPG_ERR_INV_VALUE:
+ errcode = G_IO_ERROR_INVALID_ARGUMENT;
+ break;
+
+ default:
+ errcode = G_IO_ERROR_FAILED;
+ break;
+ }
+
+ g_set_error (error, G_IO_ERROR, errcode, "%s: %s",
+ gpgme_strsource (gpg_error),
+ gpgme_strerror (gpg_error));
+}
--- /dev/null
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2015 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#pragma once
+
+#include <gpgme.h>
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+void ot_gpgme_error_to_gio_error (gpgme_error_t gpg_error, GError **error);
+
+G_END_DECLS
#include <ot-variant-utils.h>
#include <ot-spawn-utils.h>
#include <ot-checksum-utils.h>
+#include <ot-gpg-utils.h>
void ot_ptrarray_add_many (GPtrArray *a, ...) G_GNUC_NULL_TERMINATED;